package servlet.play;

import pojo.Songs;
import service.PlayListService;
import service.impl.PlayListServiceImpl;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/play/getPlaySong")
public class GetPlaySong extends HttpServlet {
    private PlayListService playListService = new PlayListServiceImpl();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取所有歌曲信息
        List<Songs> songList = playListService.selectAllSongs();

        // 将歌曲列表存储在请求域中
        request.getSession().setAttribute("songs", songList);

        // 转发请求到 playList.jsp
        RequestDispatcher dispatcher = request.getRequestDispatcher("/playlists/playlists.jsp");
        dispatcher.forward(request, response);
    }
}
